package com.wolves.career.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wolves.career.entity.JobOpportunityPosition;
import com.wolves.career.mapper.JobOpportunityPositionMapper;
import com.wolves.career.service.JobOpportunityPositionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 麦翔盛
 * @since 2021-10-23
 */
@Service
public class JobOpportunityPositionServiceImpl extends ServiceImpl<JobOpportunityPositionMapper, JobOpportunityPosition> implements JobOpportunityPositionService {
    /**
     * name heat update_time create_time
     * @param position 职位类
     * @return
     */
    @Override
    public QueryWrapper<JobOpportunityPosition> queryJobPosition(JobOpportunityPosition position) {
        if (position == null){
            return null;
        }
        //获取查询信息
        String name = position.getName();
        Integer heat = position.getHeat();
        Date updateTime = position.getUpdateTime();
        Date createTime = position.getCreateTime();
        //创建条件封装类
        QueryWrapper<JobOpportunityPosition> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("name",name);
        }
        if (!StringUtils.isEmpty(heat)){
            //查询更高的热度
            queryWrapper.gt("heat",heat);
        }
        if (!StringUtils.isEmpty(updateTime)){
            queryWrapper.lt("update_time",updateTime);
        }
        if (!StringUtils.isEmpty(createTime)){
            queryWrapper.gt("create_time",createTime);
        }
        return queryWrapper;
    }
}
